package com.haoshuang.zhouzhoubang.ui.dialog

import android.content.Context
import android.widget.EditText

import android.widget.ImageView
import android.widget.TextView
import androidx.core.widget.addTextChangedListener
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.haoshuang.zhouzhoubang.R


import com.lxj.xpopup.core.BottomPopupView
import com.mufeng.libs.utils.toast


class MarkDialog(context: Context, private val onSubmit: (str:String) -> Unit) : BottomPopupView(context){
    override fun getImplLayoutId(): Int = R.layout.dialog_mark

    override fun initPopupContent() {
        super.initPopupContent()

        var etMark=findViewById<EditText>(R.id.etMark)
        var tvNum=findViewById<TextView>(R.id.tvNum)
        var tvCommit1=findViewById<TextView>(R.id.tvCommit1)
        var tvCommit=findViewById<TextView>(R.id.tvCommit)
        etMark.addTextChangedListener {
            var desc=etMark.text.toString()
            tvNum.setText("${desc.length}/200")
        }
        tvCommit1.setOnClickListener {
            dismiss()
        }
        tvCommit.setOnClickListener {

            var desc=etMark.text.toString()
            if (desc.isNullOrBlank()){
                toast("请输入备注")
                return@setOnClickListener
            }
            dismiss()
            onSubmit(desc)
        }
    }


}